package util

import (
	"io"
	"bytes"
	"encoding/json"
)

func ToJson(any interface{},indent bool)  (io.Reader, error){
	buf := &bytes.Buffer{}
	encoder := json.NewEncoder(buf)
	if indent{
		encoder.SetIndent("", "\t")
	}
	err :=encoder.Encode(any)
	if err != nil {
		return nil, err
	}
	return buf, nil
}
